package it.unipd.dei.bd.icineasti.database;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.sql.ResultSet;

/**
 * Cancella una sala partendo dal suo idsala.
 * 
 * @author Bardelle Renzo
 * @version 1.00
 */

public class DeleteSalaDatabase {

	private static final String STATEMENT = "DELETE FROM sala WHERE idsala=?";

	private final Connection con;
	private final int idsala;

	public DeleteSalaDatabase(Connection con, int idsala) {
		this.con = con;
		this.idsala = idsala;
	}

	public void deleteSala() throws SQLException {

		PreparedStatement pstmt = null;
				
		try {
			pstmt = con.prepareStatement(STATEMENT);
			
			pstmt.setInt(1, idsala);
			
			pstmt.execute();
			
		} finally {
			if (pstmt != null) {
				pstmt.close();
			}			
		}
	}
}
